<HTML>
<HEAD>
<TITLE>[Chapter 14] 14.4 AppletStub Interface</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 14:54:05 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch14_03.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 14<br>And Then There Were Applets</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch14_05.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JAWT-CH-14-SECT-4">14.4 AppletStub Interface</A></h2>

<P CLASS=para>
<A NAME="CH14.APPLET3"></A><A NAME="CH14.APPLET3A"></A>The <tt CLASS=literal>AppletStub</tt> interface provides 
a way to get information from the run-time browser environment. The <tt CLASS=literal>Applet</tt> 
class provides methods with similar names that call these methods. Methods

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract boolean isActive () </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>isActive()</tt> method returns 
the current state of the applet. While an applet is initializing, it is 
not active, and calls to <tt CLASS=literal>isActive()</tt> 
return <tt CLASS=literal>false</tt>. The system marks the applet active just prior to calling 
<tt CLASS=literal>start()</tt>; after this point, 
calls to <tt CLASS=literal>isActive()</tt> return 
<tt CLASS=literal>true</tt>. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract URL getDocumentBase () </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>getDocumentBase()</tt> method 
returns the complete URL of the HTML 
file that loaded the applet. This method can be used with the <tt CLASS=literal>getImage()</tt> 
or <tt CLASS=literal>getAudioClip()</tt> methods to 
load an image or audio file relative to the HTML file. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract URL getCodeBase () </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>getCodeBase()</tt> method returns 
the complete URL of the .<I CLASS=emphasis>class</I> 
file that contains the applet. This method can be used with the <tt CLASS=literal>getImage()</tt> method 
or the <tt CLASS=literal>getAudioClip()</tt> method to 
load an image or audio file relative to the .<I CLASS=emphasis>class</I> 
file. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract String getParameter (String name) </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>getParameter()</tt> method allows 
you to get parameters from <tt CLASS=literal>&lt;PARAM&gt;</tt> 
tags within the <tt CLASS=literal>&lt;APPLET&gt;</tt> 
tag of the HTML file that loaded the applet. The <tt CLASS=literal>name</tt> 
parameter of <tt CLASS=literal>getParameter()</tt> 
must match the name string of the <tt CLASS=literal>&lt;PARAM&gt;</tt> 
tag; <tt CLASS=literal>name</tt> is case insensitive. 
The return value of <tt CLASS=literal>getParameter()</tt> 
is the value associated with <tt CLASS=literal>name</tt>; 
it is always a <tt CLASS=literal>String</tt> regardless 
of the type of data in the tag. If <tt CLASS=literal>name</tt> 
is not found within the <tt CLASS=literal>&lt;PARAM&gt;</tt> 
tags of the <tt CLASS=literal>&lt;APPLET&gt;</tt>, 
<tt CLASS=literal>getParameter()</tt> returns <tt CLASS=literal>null</tt>. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract AppletContext getAppletContext () </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>getAppletContext()</tt> method 
returns the current <tt CLASS=literal>AppletContext</tt> 
of the applet. This is part of the stub that is set by the system when 
<tt CLASS=literal>setStub()</tt> is called. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>public abstract void appletResize (int width, int height) </I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>appletResize()</tt> method is 
called by the resize method of the <tt CLASS=literal>Applet</tt> class. The method changes the 
size of the applet space to <tt CLASS=literal>width</tt> 
x <tt CLASS=literal>height</tt>. The browser must 
support changing the applet space; if it doesn't, the size remains 
unchanged. </DL>
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch14_03.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch14_05.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>AppletContext Interface</td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Audio in Applications</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
